﻿Imports System.Data.Common

Friend Class FakeDbProviderFactory
    Inherits DbProviderFactory
    Implements IServiceProvider

    Private ReadOnly _SqlServerYear As String

    Public Sub New(sqlServerYear As String)
        _SqlServerYear = sqlServerYear

        Instance = Me
    End Sub

    Public Shared Instance As FakeDbProviderFactory

    Public Function GetService(serviceType As System.Type) As Object Implements System.IServiceProvider.GetService
        Select Case serviceType
            Case GetType(DbProviderServices)
                Return New FakeDbServices(_SqlServerYear)
            Case Else
                Throw New NotImplementedException()
        End Select
    End Function

    Public Overrides Function CreateConnection() As DbConnection
        Return New FakeDbConnection(_SqlServerYear)
    End Function
End Class